package jwr.ex;

import java.util.Random;
import java.util.Scanner;

public class UpDown {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		 Random rand = new Random();     
		 
		 int cnt = 1;
		 int r = rand.nextInt(100);
		 int num,max,min;
		 String yorn = "y";
		 do{
			 max = 99;
			 min = 0;
			 System.out.println("수를 결정 하였습니다. 맞춰 보세요");
			 System.out.println("0-99");
			 do{
				 System.out.print(cnt+">>");
				 cnt++;
				 num = sc.nextInt();
				 if(num>r){
					 max = num-1;
					 System.out.println("더 낮게");
					 System.out.println(+min+"-"+max);
				 }else if(num<r){
					 min = num+1;
					 System.out.println("더 높게");
					 System.out.println(min+"-"+max);
				 }else{
					 System.out.println("맞았습니다.");
				 }
			 }while(r!=num);
			 System.out.println("다시 하시겠습니까?(y/n)");
			 yorn = sc.next();
		 }while(yorn.equals("y"));
		 System.out.println("종료되었습니다.");

	}

}
